/**
 * @projectName spring-boot-examples-master
 * @package com.leo.springboot.factory
 * @className com.leo.springboot.factory.StrategyFactory
 * @copyright Copyright 2020 XiaoFeiPeng, Inc All rights reserved.
 */
package com.leo.springboot.factory;

import com.leo.springboot.strategy.AutumnActivity;
import com.leo.springboot.strategy.SpringActivity;
import com.leo.springboot.strategy.Strategy;
import com.leo.springboot.strategy.SummerActivity;
import com.leo.springboot.strategy.WinterActivity;

/**
 * StrategyFactory
 * @description 策略类工厂
 * @author jiangyunfei
 * @date 2023/11/16 10:54
 * @version 1.0
 */
public class StrategyFactory {

    /**
     * 私有构造函数，防止实例化
     */
    private StrategyFactory() {}

    public static Strategy execute(Integer levelCode){
        Strategy strategy = null;
        switch (levelCode){
            case 1:
                strategy = new SpringActivity();
                break;
            case 2:
                strategy = new SummerActivity();
                break;
            case 3:
                strategy = new AutumnActivity();
                break;
            case 4:
                strategy = new WinterActivity();
                break;
            default:
                throw new IllegalArgumentException("活动编号错误:"+levelCode);
        }
        return strategy;
    }
}
